package com.cws.model;

import java.util.List;

import com.cws.dto.PageReq;
import com.cws.utils.WSUtil;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

public class SysUser extends Model<SysUser> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3895999326598666654L;

	public static final SysUser dao = new SysUser();

	public List<SysUser> getAllUser() {
		return dao.find("select * from sys_user");
	}

	public List<SysUser> getLoginUser(String loginName, String password) {
		return dao.find("select * from sysUser where loginName = ? and password = ?", loginName, password);
	}

	public Page<SysUser> getByPage(PageReq req) {

		String select = "SELECT *";
		String baseSql = "FROM sysUser WHERE 1 = 1";
		String sql = WSUtil.GenQuerySql(baseSql, req);
		Page<SysUser> page = SysUser.dao.paginate(req.getPageNumber(), req.getPageSize(), select, sql);
		
		return page;
	}
}
